package com.lmabbe.core.service.impls;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lmabbe.core.common.entitys.SysRole;
import com.lmabbe.core.common.interfaces.SysRoleService;
import com.lmabbe.core.common.query.SysRoleQuery;
import com.lmabbe.core.service.dao.SysRoleMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;

/**
 * @author lmabbe
 */
@Slf4j
@DubboService(provider = "simple-dubbo")
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {

    @Override
    public boolean containCode(String code) {
        return this.baseMapper.selectCount(lambdaQuery().eq(SysRole::getCode, code)) > 0;
    }

    @Override
    public boolean containName(String name) {
        return this.baseMapper.selectCount(lambdaQuery().eq(SysRole::getName, name)) > 0;
    }

    @Override
    public IPage selectPage(SysRoleQuery query) {
        return baseMapper.selectPage(query.createPage(), query.createQuery());
    }
}
